<template>
  <div class="message">
     <div class="title">
      <span>消息</span>
    </div>
    <ul v-for="(item,index) in messagelist" :key="index">
        <li>{{item.title}}</li>
        <li>{{item.sendDate}}</li>
    </ul>
    <div class="num">
      {{messagelength}}
    </div>
  </div>
</template>

<script>
import {defineComponent,reactive,computed} from "vue"
import { useRoute } from "vue-router"
import { useStore } from "vuex"
export default defineComponent({
  setup(Proxy,context){

    const state=reactive({
      messagelist:[],
      messagelength:[],
      mid:0,
      pageNo:1
    })

    let {mid,pageNo} =state
    let store=useStore()
    store.dispatch('message/getMessagePage',{mid,pageNo})
    return{
      messagelist:computed(()=>store.state.message.messageList),
      messagelength:computed(()=>store.state.message.messageList.length),
      state
    }

  }
})
</script>

<style lang="scss">
  .message{
  .title {
  width: 100%;
  height: 3rem;
  line-height: 3rem;
  text-align: center;
  font-size: 1.2rem;
  span {
    font-weight: 800;
  }
}
    ul{
      padding: 0 1rem;
      border:.05rem solid #eee;
      border-radius:1rem;
      margin:.8rem;
      li:nth-child(1){
        width: 100%;
        text-align: left;
        height: 3rem;
        font-size: 1.1rem;
        line-height: 3rem;
        padding-top: .6rem;
      }    
      li:nth-child(2){
        width: 100%;
        text-align: right;
        height: 2.2rem;
        line-height: 2.2rem;
        color: #ccc;
      }    
    }
    .num{
      width: 1.1rem;
      height: 1.1rem;
      background-color: red;
      color: #fff;
      font-size: .8rem;
      text-align: center;
      line-height: 1.1rem;
      border-radius: 50%;
      position: absolute;
      bottom: 2.3rem;
      right:8.3rem
    }
  }
</style>